/* 
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// --------------------------------------------------------------------------------------------------
// This file was automatically generated by J2CS Translator (http://j2cstranslator.sourceforge.net/). 
// Version 1.3.6.20101125_01     
// 12/1/10 3:36 PM    
// ${CustomMessageForDisclaimer}                                                                             
// --------------------------------------------------------------------------------------------------
namespace ILOG.J2CsMapping.Text
{
	
	using System;
	using System.Collections;
	using System.Collections.Generic;
	using System.ComponentModel;
	using System.IO;
	using System.Runtime.CompilerServices;
	
	/// <summary>
	/// ParsePosition is used to track the current position in a String being parsed.
	/// </summary>
	///
	public class ParsePosition {
	
		private int currentPosition, errorIndex;
	
		/// <summary>
		/// Constructs a new ParsePosition at the specified index.
		/// </summary>
		///
		/// <param name="index">the index to begin parsing</param>
		public ParsePosition(int index) {
			this.errorIndex = -1;
			currentPosition = index;
		}
	
		/// <summary>
		/// Compares the specified object to this ParsePosition and answer if they
		/// are equal. The object must be an instance of ParsePosition and have the
		/// same index and error index.
		/// </summary>
		///
		/// <param name="object">the object to compare with this object</param>
		/// <returns>true if the specified object is equal to this ParsePosition,
		/// false otherwise</returns>
		/// <seealso cref="M:ILOG.J2CsMapping.Text2.ParsePosition.HashCode"/>
		public override bool Equals(Object obj0) {
			if (!(obj0   is  ParsePosition)) {
				return false;
			}
			ParsePosition pos = (ParsePosition) obj0;
			return currentPosition == pos.currentPosition
					&& errorIndex == pos.errorIndex;
		}
	
		/// <summary>
		/// Answers the index at which the parse could not continue.
		/// </summary>
		///
		/// <returns>the index of the parse error, or -1 if there is no error</returns>
		public int GetErrorIndex() {
			return errorIndex;
		}
	
		/// <summary>
		/// Answers the current parse position.
		/// </summary>
		///
		/// <returns>the current position</returns>
		public int GetIndex() {
			return currentPosition;
		}
	
		/// <summary>
		/// Answers an integer hash code for the receiver. Objects which are equal
		/// answer the same value for this method.
		/// </summary>
		///
		/// <returns>the receiver's hash</returns>
		/// <seealso cref="M:ILOG.J2CsMapping.Text2.ParsePosition.Equals(System.Object)"/>
		public override int GetHashCode() {
			return currentPosition + errorIndex;
		}
	
		/// <summary>
		/// Sets the index at which the parse could not continue.
		/// </summary>
		///
		/// <param name="index">the index of the parse error</param>
		public void SetErrorIndex(int index) {
			errorIndex = index;
		}
	
		/// <summary>
		/// Sets the current parse position.
		/// </summary>
		///
		/// <param name="index">the current parse position</param>
		public void SetIndex(int index) {
			currentPosition = index;
		}
	
		/// <summary>
		/// Answers the string representation of this FieldPosition.
		/// </summary>
		///
		/// <returns>the string representation of this FieldPosition</returns>
		public override String ToString() {
			return GetType().FullName + "[index=" + currentPosition //$NON-NLS-1$
					+ ", errorIndex=" + errorIndex + "]"; //$NON-NLS-1$ //$NON-NLS-2$
		}
	}
}
